<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" rel="stylesheet">
    <!-- <script src="http://sdk.talkingdata.com/app/h5/v1?appid=DE13C350F41F5DE78FEC51DB5DE730D1&vn=v2&vc=v2"></script> -->
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js{$Think.config.RESOURCE_VER}"></script>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js{$Think.config.RESOURCE_VER}"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript" src="{$Think.config.RESOURCEURL}wx_assets/js/wx_share.js{$Think.config.RESOURCE_VER}"></script>
    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js{$Think.config.RESOURCE_VER}" type="text/javascript"></script>
    <title></title>
    <style>
        .container{
            padding:0 10px;
            color:#333333;
        }
        .container>img{
            width:150px;
            height:150px;
            border-radius: 50%;
            display: block;
            margin:45px auto 0;
        }
        .container>h1{
            text-align: center;
            font-size: 18px;
            margin-top: 30px;
        }
        .container>h1>span{
            color: #FF9900;
        }
        .container>p{
            color: #878585;
            line-height: 22px;
            font-size: 15px;
            margin-top: 10px;
        }
        .container>a{
            margin-top:28px;
            background-color:#FF9900;
            display:block;
            border-radius:4px;
            text-align: center;
            color:white;
            padding: 10px 0;
            font-size:18px;
        }
        .container>a.disabled{
            background-color:#ccc;
            color:white;
        }
    </style>
</head>
<body>
    <div class="container">
        <img src="{$Think.config.RESOURCEURL}wx_assets/community/images/teamLogo.png{$Think.config.RESOURCE_VER}"/>
        <h1><span>{$nickname}</span>邀请您加入团队</h1>
        <p>1.您只能选择一个团队，请慎重考虑后再选择加入。</p>
        <p>2.一旦加入团队后，您不能自行退出团队。</p>
        <if condition="$userInfo eq ''">
            <a class="disabled" id="join">您还不是密友，无法加入团队。</a>
            <elseif condition="$userInfo.teamId neq ''"/>
            <a class="disabled" id="join">您已经加入了一个团队。</a>
            <else/>
            <a class="disabled" id="join">立即加入（有效期<span id="time"></span>秒）</a>
        </if>
    </div>
</body>
<script>
    var baseUrl = '{$Think.config.SERVER_HOST}';
    var hrefPath = baseUrl+'call.html?customerId={$customerId}';
    var invite={
        init:function(){
            this._initTime();
            this._initEvent();
        },
        _initTime:function(){
            if($("#time").length<=0){return;}
            var time = '{$time}';
            var nowTime =new Date().getTime();
            var ss = 300 - parseInt((nowTime-time)/1000);
            if(ss>0){
                $("#time").text(ss);
                $("#join").removeClass("disabled");
                var interval = setInterval(function(){
                    if(ss<=0){
                        clearInterval(interval);
                        $("#join").addClass("disabled");
                    }
                    $("#time").text(ss);
                    ss--;
                },1000);
            }else{
                $("#time").text(0);
            }
        },
        _initEvent:function(){
            var me =this;
            $("#join").click(function(){
                if($(this).hasClass("disabled")){return;}
                var p=$.util.getParamAsObject();
                $.req.get("call.json?customerId={$customerId}&module=community&method=joinTeam",{
                    params:{"id": p.id}
                },function(data){
                    if(!data.code){
                        $.util.alert("您已经加入了团队");
                        $("#join").text("您已经加入了团队").addClass("disabled");
                    } else {
                        $.util.alert(data.msg);
                    }
                });
            });
        }
    };
    invite.init();
</script>
<script>
    wx_share.init({
        "title":"{$nickname}邀请您加入团队",
        "desc":'加入团队，我们一起变得更强大！',
        "link":window.location.href,
        "imgUrl": '{$headimgurl}',
        "pkg":{
            "appId": '{$pkg.appId}',
            "timestamp": '{$pkg.timestamp}',
            "nonceStr": '{$pkg.nonceStr}',
            "signature": '{$pkg.signature}'
        },
        success:function(config,shareType){
        }
    });
</script>
</html>